module agbutton
import StdEnv, japi

/* *********************************
This example shows how to create a graphic button.
You must keep the image file in the folder, where
you will start the exec file.
***************************************/

Start world
# (js, world) = begin_japi world
# (frm, js) = jnewFrame  (WH 400 350) "Counter" js
# (tens, js) = jnew7seg (XYWH 80 100 60 80) 0 J_GREEN frm js
# (units, js) = jnew7seg  (XY 240 100) 0 J_GREEN frm js
# frm= bg_color black frm 
# (mp, js) = jnewButton  (XY 80 250) "nextbutton.gif" frm js
# (frm, js) = jshow frm js
# js= loop  frm mp tens units 0 js
= end_japi js world
where
    loop :: !Framer !TDev !D !D !Int !*JS -> *JS
    loop frm bt tens units v js
       # (na, js) = jnextaction js
       | na== (act frm) = jquit js
       | na== (act bt)
           # v1= (v+1) rem 100
           # (tens, js)= jsetval tens (v1/10) js
             (units, js) = jsetval units (v1 rem 10) js
           = loop frm bt tens units v1 js
       | otherwise= loop frm bt tens units v js
    
 